import axios from 'axios'
import store from '@/store/index.js'
console.log('store', store)
// import JSONbig from "json-bigint"
// axios.defaults.baseURL = ''
const instance1 = axios.create({
  baseURL: 'http://ttapi.research.itcast.cn', // 后端小张同学写的
  timeout: 5000
  // headers: { 'X-Custom-Header': 'foobar' }
})
// 添加请求拦截器
instance1.interceptors.request.use(function (config) {
  const token = store.state.tokenInfo.token
  if (token) {
    config.headers.Authorization = `Bearer ${token}`
  }
  return config
}, function (error) {
  return Promise.reject(error)
})

const instance2 = axios.create({
  baseURL: 'http://api-toutiao-web.itheima.net', // 后端老王同学写的
  timeout: 3000
  // headers: { 'X-Custom-Header': 'foobar' }
})

export {
  instance1, instance2
}
export default instance1
